Docker optimizing idle CPU usage
Docker homelab energy conservation
TLDR
Add this to your docker-compose.yml
healthcheck:
disable: true
To check which services need it, use: Beszel
Prelude
I self host a bunch of services on my home server. And i care about the energy usage. Hence i chose a new enough computer to have a somewhat efficient CPU. (specs below)
_,met$$$$$gg. ,g$$$$$$$$$$$$$$$P. ,g$$P" """Y$$.". ,$$P' `$$$. ',$$P ,ggs. `$$b: `d$$' ,$P"' . $$$ $$P d$' , $$P $$: $$. - ,d$$' $$; Y$b._ _,d$P' Y$$. `.`"Y$$$$P"' `$$b "-.__ `Y$$ `Y$$. `$$b. `Y$$b. `"Y$b._ `""" user@home-server ---------------- OS: Debian GNU/Linux 12 (bookworm) x86_64 Host: HP EliteDesk 800 G3 SFF Kernel: 6.1.0-32-amd64 Uptime: 10 days, 19 hours, 29 mins Packages: 2537 (dpkg), 7 (flatpak) Shell: bash 5.2.15 Terminal: /dev/pts/1 CPU: Intel i5-7500 (4) @ 3.800GHz GPU: Intel HD Graphics 630 Memory: 3124MiB / 15400MiB
I chose to my home services using docker, which has been great, since it allows me manage many services easily. They even update themselves using Watchtower.
Observability
However, i lacked observability into resource usage.
cAdvisor
At first i tried a stack consisting of Grafana Prometheus, and cAdvisor How ever, the only conclusion i came to running this was that my CPU load now was ≈ 30% higher (if memory serves me)
This defeats the purpose for my usage... I'm sure cAdvisor has it's place, but it's not suitable for my use case.
Beszel
Then i found Beszel which is docker / system monitoring in a box. Using a minimum of system resources.
Running this for a month gave me insights into my resource usage. With averages, and a breakdown per container.
Resource usage BEFORE

Optimizing
Beszels CPU usage breakdown per container helps you drill down which container is weighing down your system. Stoping the ones you don't need and, searching the respective projects github issues helps you find solutions.
As per this github issue: High CPU (5-20%) consumption even when not being used
Adding the following segment to you docker compose files helps lower their CPU usage.
healthcheck:
disable: true
Resource usage after

Comments